home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Nov, 1999
- // Author: bb
- //
- // Procedure Name:
- // doExportClipArgList
- //
- // Description:
- // Export a clip
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- //
- // $args
- // Version 1
- // [0] $editor: name of TraxEditor window or "" if none
- // Version 2
- // [0] $editor: name of TraxEditor window or "" if none
- // [1] $clipName: name of clipName. If specified, this clip overrides the selected clips.
- //
- //
- global string $expClipEditor = "";
- global string $expClipName = "";
-
- global proc int
- clipEditorExportClip(string $fileName, string $fileType)
- {
- global string $expClipEditor;
- global string $expClipName;
-
- if ($fileName == "") {
- error("No file name was specified.");
- return 0;
- }
-
- if (`about -evalVersion`) {
- $fileType = "mayaPLE";
- }
-
- if ($fileType == "ma") {
- $fileType = "mayaAscii";
- } else if ($fileType == "mb") {
- $fileType = "mayaBinary";
- } else if ($fileType != "mayaBinary" && $fileType != "mayaAscii" && $fileType != "mayaPLE") {
- error("Invalid file type for clip export: "+$fileType);
- return 0;
- }
-
- int $ii;
- string $selClips[];
- if ($expClipName != "") {
- $selClips[0] = $expClipName;
- }
- else if ($expClipEditor == "") {
- $selClips = `ls -sl -type animClip`;
- } else {
- string $sel[];
- $sel = `clipEditor -q -sc $expClipEditor`;
- int $selSize = size($sel);
- for ($ii = 0; $ii < $selSize; $ii += 2) {
- string $sch = $sel[$ii];
- int $clipIndex = $sel[$ii+1];
- string $clipName = `clipSchedule -ci $clipIndex -q -n $sch`;
- $selClips[size($selClips)] = $clipName;
- }
- }
- if (size($selClips) == 0) {
- error("Select clips to be exported.");
- }
-
- string $sourceClips[];
- for ($clipName in $selClips) {
- string $sourceClipName = `clip -q -scn $clipName`;
- int $found = 0;
- for ($item in $sourceClips) {
- if ($item == $sourceClipName) {
- $found = 1;
- break;
- }
- }
- if (! $found) {
- $sourceClips[size($sourceClips)] = $sourceClipName;
- }
- }
-
- if (size($sourceClips) == 0) {
- error("Found no source clips for the selected clips.");
- return 0;
- }
-
- // save the current selection to restore it at the end
- //
- string $sel[] = `ls -sl`;
-
- // create the command string
- //
- string $result[];
- string $isolateCmd = "clip -isolate";
- string $clipNames = "";
- for ($clip in $sourceClips) {
- $clipNames += (" -name "+$clip);
- }
- $isolateCmd += $clipNames;
- catch($result = eval($isolateCmd));
-
- if (size($result)) {
- select -r $result;
- file -type $fileType -exportSelected -channels true -constructionHistory true $fileName;
- $lib = `ls -type clipLibrary $result`;
- if (size($lib)) {
- delete $lib;
- }
- } else {
- select -r $sel;
- error("Unable to export. See script editor for details.");
- }
-
- // restore selection
- //
- select -r $sel;
- return 1;
- }
-
- global proc
- doExportClipArgList( string $version, string $args[] )
- {
- int $versionNo = $version;
-
- global string $expClipEditor;
- global string $expClipName;
- $expClipEditor = $args[0];
-
- if ($versionNo > 1) {
- $expClipName = $args[1];
- } else {
- $expClipName = "";
- }
-
- string $sc[];
- if ($expClipName != "") {
- $sc[0] = $expClipName;
- } else {
- if ($expClipEditor == "") {
- $sc = `ls -sl -type animClip`;
- } else {
- $sc = `clipEditor -q -sc $expClipEditor`;
- }
- }
-
- if (size($sc) == 0) {
- error("Select the clip to be exported.");
- }
-
- string $clipsDir = (`workspace -q -rd`+"clips\/");
- if (`file -q -ex $clipsDir`) {
- workspace -dir $clipsDir;
- }
- // bring up the file browser dialog so that they can choose a file name
- //
- fileBrowser("clipEditorExportClip","Export Clip","ma",1);
- }
-